import React, { useRef, useState } from 'react';
import { useFrame, useThree } from '@react-three/fiber';
import { Text, Box, Sphere, Cylinder, Cone, Plane, RoundedBox } from '@react-three/drei';
import type { DatingProfile } from '../types';
import * as THREE from 'three';

interface UltraFemaleCharacterProps {
  profile: DatingProfile;
  position: [number, number, number];
  rotation?: [number, number, number];
  onClick: () => void;
  scale?: number;
  isSeated?: boolean;
}

export const UltraFemaleCharacter3D: React.FC<UltraFemaleCharacterProps> = ({
  profile,
  position,
  rotation = [0, 0, 0],
  onClick,
  scale = 1,
  isSeated = false
}) => {
  const characterRef = useRef<THREE.Group>(null);
  const [hovered, setHovered] = useState(false);
  const [clicked, setClicked] = useState(false);
  const { camera } = useThree();

  // 优雅稳定的动画系统
  useFrame((state) => {
    if (characterRef.current) {
      // 最小化所有动画，确保稳定性
      const breathScale = 1 + Math.sin(state.clock.elapsedTime * 0.6) * 0.002;
      characterRef.current.scale.set(scale * breathScale, scale * breathScale, scale * breathScale);
      
      // 完全固定旋转，防止后倾
      characterRef.current.rotation.set(rotation[0], rotation[1], rotation[2]);
    }
  });

  const handleClick = () => {
    setClicked(true);
    setTimeout(() => setClicked(false), 400);
    onClick();
  };

  const handlePointerOver = () => {
    setHovered(true);
    document.body.style.cursor = 'pointer';
  };

  const handlePointerOut = () => {
    setHovered(false);
    document.body.style.cursor = 'default';
  };

  // 高端女性材质系统
  const materials = {
    skin: { color: '#F5C6A0', roughness: 0.82, metalness: 0.02 },
    hair: { color: '#8B4513', roughness: 0.85, metalness: 0.0 },
    dress: { color: '#C53030', roughness: 0.65, metalness: 0.05 },
    accent: { color: '#FED7D7', roughness: 0.7, metalness: 0.1 },
    shoes: { color: '#B91C1C', roughness: 0.3, metalness: 0.6 },
    jewelry: { color: '#ECC94B', roughness: 0.1, metalness: 0.95 },
    lips: { color: '#E53E3E', roughness: 0.2, metalness: 0.3 },
    eyes: { color: '#2D3748', roughness: 0.15, metalness: 0.0 },
    nails: { color: '#FBB6CE', roughness: 0.1, metalness: 0.4 }
  };

  const sittingAdjust = isSeated ? { torso: -0.18, dress: -0.15, legs: -0.3, feet: -0.5 } : { torso: 0, dress: 0, legs: 0, feet: 0 };

  return (
    <group 
      ref={characterRef}
      position={position}
      rotation={rotation}
      onClick={handleClick}
      onPointerOver={handlePointerOver}
      onPointerOut={handlePointerOut}
    >
      {/* ========== 精致身体建模系统 ========== */}
      
      {/* 女性躯干 - 曲线美学 */}
      <group position={[0, 0.8 + sittingAdjust.torso, 0]}>
        {/* 胸部区域 - 自然曲线 */}
        <Sphere position={[0, 0.12, 0]} args={[0.22, 0.28, 0.18]} castShadow receiveShadow>
          <meshStandardMaterial {...materials.dress} />
        </Sphere>
        
        {/* 腰部收紧 - 女性特征 */}
        <Cylinder position={[0, -0.05, 0]} args={[0.16, 0.2, 0.22]} castShadow receiveShadow>
          <meshStandardMaterial {...materials.dress} />
        </Cylinder>
        
        {/* 臀部曲线 */}
        <Sphere position={[0, -0.22, 0]} args={[0.18, 0.15, 0.16]} castShadow>
          <meshStandardMaterial {...materials.dress} />
        </Sphere>

        {/* 连衣裙上身装饰 */}
        <Cylinder position={[0, -0.08, 0]} args={[0.18, 0.18, 0.04]} castShadow>
          <meshStandardMaterial {...materials.accent} />
        </Cylinder>
        
        {/* 胸前蝴蝶结 */}
        <group position={[0, 0.22, 0.12]}>
          <Box args={[0.08, 0.04, 0.02]} castShadow>
            <meshStandardMaterial {...materials.accent} />
          </Box>
          <Box position={[-0.05, 0, 0.01]} args={[0.03, 0.06, 0.015]} rotation={[0, 0, 0.3]} castShadow>
            <meshStandardMaterial {...materials.accent} />
          </Box>
          <Box position={[0.05, 0, 0.01]} args={[0.03, 0.06, 0.015]} rotation={[0, 0, -0.3]} castShadow>
            <meshStandardMaterial {...materials.accent} />
          </Box>
        </group>

        {/* 肩带细节 */}
        <Cylinder position={[-0.15, 0.18, 0.05]} args={[0.015, 0.015, 0.25]} rotation={[0.3, 0, 0.2]} castShadow>
          <meshStandardMaterial {...materials.dress} />
        </Cylinder>
        <Cylinder position={[0.15, 0.18, 0.05]} args={[0.015, 0.015, 0.25]} rotation={[0.3, 0, -0.2]} castShadow>
          <meshStandardMaterial {...materials.dress} />
        </Cylinder>
      </group>

      {/* 优美裙摆系统 */}
      <group position={[0, isSeated ? 0.4 : 0.32, sittingAdjust.dress]}>
        {/* 主裙摆 - 多层设计 */}
        <Cone
          args={[isSeated ? 0.4 : 0.5, isSeated ? 0.25 : 0.45, 16]}
          castShadow
          receiveShadow
        >
          <meshStandardMaterial {...materials.dress} />
        </Cone>
        
        {/* 内层裙摆 */}
        <Cone
          position={[0, -0.05, 0]}
          args={[isSeated ? 0.35 : 0.45, isSeated ? 0.2 : 0.35, 12]}
          castShadow
        >
          <meshStandardMaterial {...materials.accent} />
        </Cone>
        
        {/* 裙摆花边装饰 */}
        {!isSeated && Array.from({ length: 12 }, (_, i) => {
          const angle = (i * Math.PI * 2) / 12;
          return (
            <group key={i}>
              <Sphere
                position={[
                  Math.cos(angle) * 0.48,
                  -0.18,
                  Math.sin(angle) * 0.48
                ]}
                args={[0.02]}
                castShadow
              >
                <meshStandardMaterial {...materials.accent} />
              </Sphere>
              
              {/* 蕾丝边细节 */}
              <Cylinder
                position={[
                  Math.cos(angle) * 0.46,
                  -0.15,
                  Math.sin(angle) * 0.46
                ]}
                args={[0.008, 0.008, 0.08]}
                rotation={[0, angle, 0]}
                castShadow
              >
                <meshStandardMaterial color="#FFFFFF" roughness={0.8} />
              </Cylinder>
            </group>
          );
        })}
      </group>

      {/* ========== 精致手臂建模 ========== */}
      
      {/* 左臂完整系统 */}
      <group>
        {/* 肩膀连接 - 柔和曲线 */}
        <Sphere position={[-0.25, 0.88 + sittingAdjust.torso, 0]} args={[0.07]} castShadow>
          <meshStandardMaterial {...materials.skin} />
        </Sphere>
        
        {/* 上臂 - 纤细优美 */}
        <Cylinder
          position={[-0.35, 0.72 + sittingAdjust.torso, 0]}
          args={[0.05, 0.06, 0.28]}
          rotation={[0, 0, isSeated ? 0.5 : 0.15]}
          castShadow
        >
          <meshStandardMaterial {...materials.skin} />
        </Cylinder>
        
        {/* 肘部关节 */}
        <Sphere 
          position={[-0.42, 0.58 + sittingAdjust.torso, isSeated ? 0.08 : 0]} 
          args={[0.04]} 
          castShadow
        >
          <meshStandardMaterial {...materials.skin} />
        </Sphere>
        
        {/* 前臂 */}
        <Cylinder
          position={[-0.48, 0.45 + sittingAdjust.torso, isSeated ? 0.12 : 0]}
          args={[0.04, 0.05, 0.24]}
          rotation={[0, 0, isSeated ? -0.4 : 0.1]}
          castShadow
        >
          <meshStandardMaterial {...materials.skin} />
        </Cylinder>
        
        {/* 手腕 */}
        <Sphere 
          position={[-0.54, 0.33 + sittingAdjust.torso, isSeated ? 0.18 : 0]} 
          args={[0.035]} 
          castShadow
        >
          <meshStandardMaterial {...materials.skin} />
        </Sphere>
        
        {/* 左手精细建模 */}
        <group position={[-0.58, 0.3 + sittingAdjust.torso, isSeated ? 0.22 : 0]}>
          {/* 手掌 - 纤细 */}
          <Box args={[0.065, 0.05, 0.1]} castShadow>
            <meshStandardMaterial {...materials.skin} />
          </Box>
          
          {/* 五指精细建模 */}
          {Array.from({ length: 5 }, (_, i) => {
            const fingerLengths = [0.02, 0.032, 0.035, 0.03, 0.025]; // 拇指到小指
            const fingerPositions = [
              [-0.025, -0.01, 0.06], // 拇指
              [-0.02, 0, 0.08],      // 食指
              [0, 0, 0.085],         // 中指
              [0.02, 0, 0.08],       // 无名指
              [0.035, 0, 0.07]       // 小指
            ];
            
            return (
              <group key={i}>
                {/* 手指主体 */}
                <Cylinder
                  position={fingerPositions[i]}
                  args={[0.006, 0.006, fingerLengths[i]]}
                  castShadow
                >
                  <meshStandardMaterial {...materials.skin} />
                </Cylinder>
                
                {/* 指甲 - 美甲效果 */}
                <Sphere
                  position={[
                    fingerPositions[i][0],
                    fingerPositions[i][1],
                    fingerPositions[i][2] + fingerLengths[i]/2 + 0.008
                  ]}
                  args={[0.004]}
                  castShadow
                >
                  <meshStandardMaterial {...materials.nails} />
                </Sphere>
                
                {/* 指关节细节 */}
                <Sphere
                  position={[
                    fingerPositions[i][0],
                    fingerPositions[i][1],
                    fingerPositions[i][2] + fingerLengths[i]/4
                  ]}
                  args={[0.008]}
                  castShadow
                >
                  <meshStandardMaterial {...materials.skin} />
                </Sphere>
              </group>
            );
          })}
        </group>

        {/* 精美手镯系统 */}
        <group position={[-0.54, 0.36 + sittingAdjust.torso, isSeated ? 0.18 : 0]}>
          {/* 主手镯 */}
          <Cylinder args={[0.04, 0.04, 0.02]} rotation={[Math.PI/2, 0, 0]} castShadow>
            <meshStandardMaterial {...materials.jewelry} />
          </Cylinder>
          
          {/* 宝石装饰 */}
          {Array.from({ length: 8 }, (_, i) => {
            const angle = (i * Math.PI * 2) / 8;
            const colors = ["#FF1493", "#00CED1", "#32CD32", "#FFD700"];
            return (
              <Sphere
                key={i}
                position={[
                  Math.cos(angle) * 0.04,
                  0,
                  Math.sin(angle) * 0.04
                ]}
                args={[0.006]}
                castShadow
              >
                <meshStandardMaterial 
                  color={colors[i % colors.length]} 
                  roughness={0.1} 
                  metalness={0.8}
                />
              </Sphere>
            );
          })}
        </group>
      </group>

      {/* 右臂系统 - 对称但优化 */}
      <group>
        <Sphere position={[0.25, 0.88 + sittingAdjust.torso, 0]} args={[0.07]} castShadow>
          <meshStandardMaterial {...materials.skin} />
        </Sphere>
        
        <Cylinder
          position={[0.35, 0.72 + sittingAdjust.torso, 0]}
          args={[0.05, 0.06, 0.28]}
          rotation={[0, 0, isSeated ? -0.5 : -0.15]}
          castShadow
        >
          <meshStandardMaterial {...materials.skin} />
        </Cylinder>
        
        <Sphere 
          position={[0.42, 0.58 + sittingAdjust.torso, isSeated ? 0.08 : 0]} 
          args={[0.04]} 
          castShadow
        >
          <meshStandardMaterial {...materials.skin} />
        </Sphere>
        
        <Cylinder
          position={[0.48, 0.45 + sittingAdjust.torso, isSeated ? 0.12 : 0]}
          args={[0.04, 0.05, 0.24]}
          rotation={[0, 0, isSeated ? 0.4 : -0.1]}
          castShadow
        >
          <meshStandardMaterial {...materials.skin} />
        </Cylinder>
        
        <Sphere 
          position={[0.54, 0.33 + sittingAdjust.torso, isSeated ? 0.18 : 0]} 
          args={[0.035]} 
          castShadow
        >
          <meshStandardMaterial {...materials.skin} />
        </Sphere>
        
        {/* 右手 */}
        <group position={[0.58, 0.3 + sittingAdjust.torso, isSeated ? 0.22 : 0]}>
          <Box args={[0.065, 0.05, 0.1]} castShadow>
            <meshStandardMaterial {...materials.skin} />
          </Box>
          
          {Array.from({ length: 5 }, (_, i) => {
            const fingerLengths = [0.02, 0.032, 0.035, 0.03, 0.025];
            const fingerPositions = [
              [0.025, -0.01, 0.06],
              [0.02, 0, 0.08],
              [0, 0, 0.085],
              [-0.02, 0, 0.08],
              [-0.035, 0, 0.07]
            ];
            
            return (
              <group key={i}>
                <Cylinder
                  position={fingerPositions[i]}
                  args={[0.006, 0.006, fingerLengths[i]]}
                  castShadow
                >
                  <meshStandardMaterial {...materials.skin} />
                </Cylinder>
                
                <Sphere
                  position={[
                    fingerPositions[i][0],
                    fingerPositions[i][1],
                    fingerPositions[i][2] + fingerLengths[i]/2 + 0.008
                  ]}
                  args={[0.004]}
                  castShadow
                >
                  <meshStandardMaterial {...materials.nails} />
                </Sphere>
              </group>
            );
          })}
        </group>
      </group>

      {/* ========== 腿部和鞋子系统 ========== */}
      
      {/* 大腿 - 只在需要时显示 */}
      {!isSeated && (
        <group position={[0, sittingAdjust.legs, 0]}>
          <Cylinder position={[-0.08, 0.08, 0]} args={[0.06, 0.07, 0.16]} castShadow>
            <meshStandardMaterial {...materials.skin} />
          </Cylinder>
          <Cylinder position={[0.08, 0.08, 0]} args={[0.06, 0.07, 0.16]} castShadow>
            <meshStandardMaterial {...materials.skin} />
          </Cylinder>
        </group>
      )}

      {/* 奢华高跟鞋 - 只站立时 */}
      {!isSeated && (
        <group position={[0, sittingAdjust.feet, 0]}>
          {/* 左鞋完整系统 */}
          <group position={[-0.08, 0.04, 0]}>
            {/* 鞋面 */}
            <RoundedBox args={[0.11, 0.07, 0.24]} radius={0.02} castShadow receiveShadow>
              <meshStandardMaterial {...materials.shoes} />
            </RoundedBox>
            
            {/* 鞋跟 - 细高跟 */}
            <Cylinder position={[0, -0.12, -0.08]} args={[0.008, 0.015, 0.16]} castShadow>
              <meshStandardMaterial {...materials.shoes} />
            </Cylinder>
            
            {/* 鞋底 */}
            <RoundedBox position={[0, -0.05, 0]} args={[0.12, 0.02, 0.26]} radius={0.01} castShadow>
              <meshStandardMaterial color="#2F2F2F" roughness={0.8} />
            </RoundedBox>
            
            {/* 鞋面装饰 - 蝴蝶结 */}
            <group position={[0, 0.05, 0.1]}>
              <Box args={[0.04, 0.02, 0.01]} castShadow>
                <meshStandardMaterial {...materials.accent} />
              </Box>
              <Box position={[-0.025, 0, 0.005]} args={[0.02, 0.03, 0.008]} rotation={[0, 0, 0.3]} castShadow>
                <meshStandardMaterial {...materials.accent} />
              </Box>
              <Box position={[0.025, 0, 0.005]} args={[0.02, 0.03, 0.008]} rotation={[0, 0, -0.3]} castShadow>
                <meshStandardMaterial {...materials.accent} />
              </Box>
            </group>
            
            {/* 侧面装饰钻石 */}
            {Array.from({ length: 6 }, (_, i) => (
              <Sphere
                key={i}
                position={[0.055, 0.02, -0.08 + i * 0.03]}
                args={[0.004]}
                castShadow
              >
                <meshStandardMaterial 
                  color="#FFFFFF" 
                  roughness={0.0} 
                  metalness={0.9}
                  transparent
                  opacity={0.9}
                />
              </Sphere>
            ))}
          </group>
          
          {/* 右鞋 - 镜像设计 */}
          <group position={[0.08, 0.04, 0]}>
            <RoundedBox args={[0.11, 0.07, 0.24]} radius={0.02} castShadow receiveShadow>
              <meshStandardMaterial {...materials.shoes} />
            </RoundedBox>
            
            <Cylinder position={[0, -0.12, -0.08]} args={[0.008, 0.015, 0.16]} castShadow>
              <meshStandardMaterial {...materials.shoes} />
            </Cylinder>
            
            <RoundedBox position={[0, -0.05, 0]} args={[0.12, 0.02, 0.26]} radius={0.01} castShadow>
              <meshStandardMaterial color="#2F2F2F" roughness={0.8} />
            </RoundedBox>
            
            <group position={[0, 0.05, 0.1]}>
              <Box args={[0.04, 0.02, 0.01]} castShadow>
                <meshStandardMaterial {...materials.accent} />
              </Box>
              <Box position={[-0.025, 0, 0.005]} args={[0.02, 0.03, 0.008]} rotation={[0, 0, 0.3]} castShadow>
                <meshStandardMaterial {...materials.accent} />
              </Box>
              <Box position={[0.025, 0, 0.005]} args={[0.02, 0.03, 0.008]} rotation={[0, 0, -0.3]} castShadow>
                <meshStandardMaterial {...materials.accent} />
              </Box>
            </group>
            
            {Array.from({ length: 6 }, (_, i) => (
              <Sphere
                key={i}
                position={[-0.055, 0.02, -0.08 + i * 0.03]}
                args={[0.004]}
                castShadow
              >
                <meshStandardMaterial 
                  color="#FFFFFF" 
                  roughness={0.0} 
                  metalness={0.9}
                  transparent
                  opacity={0.9}
                />
              </Sphere>
            ))}
          </group>
        </group>
      )}

      {/* ========== 超精细头部系统 ========== */}
      
      {/* 优美颈部 */}
      <Cylinder
        position={[0, 1.05 + sittingAdjust.torso, 0]}
        args={[0.05, 0.05, 0.15]}
        castShadow
      >
        <meshStandardMaterial {...materials.skin} />
      </Cylinder>

      {/* 女性头型 - 椭圆形 */}
      <Sphere
        position={[0, 1.2 + sittingAdjust.torso, 0]}
        args={[0.15, 20, 20]}
        castShadow
      >
        <meshStandardMaterial {...materials.skin} />
      </Sphere>

      {/* 精致发型系统 */}
      <group position={[0, 1.2 + sittingAdjust.torso, 0]}>
        {/* 主发型 - 波浪长发 */}
        <Sphere position={[0, 0.1, -0.08]} args={[0.18, 20, 20]} castShadow>
          <meshStandardMaterial {...materials.hair} />
        </Sphere>
        
        {/* 侧发卷 */}
        <Sphere position={[-0.16, 0.05, -0.12]} args={[0.12, 16, 16]} castShadow>
          <meshStandardMaterial {...materials.hair} />
        </Sphere>
        <Sphere position={[0.16, 0.05, -0.12]} args={[0.12, 16, 16]} castShadow>
          <meshStandardMaterial {...materials.hair} />
        </Sphere>
        
        {/* 后发 - 长发飘逸 */}
        <Sphere position={[0, -0.05, -0.22]} args={[0.16, 16, 16]} castShadow>
          <meshStandardMaterial {...materials.hair} />
        </Sphere>
        
        {/* 发束细节 */}
        {Array.from({ length: 16 }, (_, i) => {
          const angle = (i * Math.PI * 2) / 16;
          const radius = 0.15 + Math.random() * 0.03;
          return (
            <Cylinder
              key={i}
              position={[
                Math.cos(angle) * radius,
                0.08 + Math.random() * 0.04,
                -0.08 + Math.sin(angle) * radius
              ]}
              args={[0.006, 0.004, 0.12 + Math.random() * 0.08]}
              rotation={[Math.random() * 0.3, angle, Math.random() * 0.2]}
              castShadow
            >
              <meshStandardMaterial {...materials.hair} />
            </Cylinder>
          );
        })}
        
        {/* 精美发饰 */}
        <group position={[0.12, 0.15, 0.08]}>
          {/* 发夹主体 */}
          <Box args={[0.06, 0.02, 0.01]} castShadow>
            <meshStandardMaterial {...materials.jewelry} />
          </Box>
          
          {/* 装饰花朵 */}
          <Sphere position={[0, 0.015, 0.008]} args={[0.015]} castShadow>
            <meshStandardMaterial color="#FF69B4" roughness={0.3} />
          </Sphere>
          
          {/* 花瓣 */}
          {Array.from({ length: 6 }, (_, i) => {
            const angle = (i * Math.PI * 2) / 6;
            return (
              <Sphere
                key={i}
                position={[
                  Math.cos(angle) * 0.02,
                  0.015,
                  0.008 + Math.sin(angle) * 0.02
                ]}
                args={[0.008]}
                castShadow
              >
                <meshStandardMaterial color="#FFB6C1" roughness={0.4} />
              </Sphere>
            );
          })}
        </group>
      </group>

      {/* ========== 超精细面部特征 ========== */}
      
      <group position={[0, 1.2 + sittingAdjust.torso, 0]}>
        {/* 眼部化妆区域 */}
        <Box position={[-0.045, 0.025, 0.13]} args={[0.035, 0.02, 0.02]} castShadow>
          <meshStandardMaterial color="#E6E6FA" roughness={0.6} />
        </Box>
        <Box position={[0.045, 0.025, 0.13]} args={[0.035, 0.02, 0.02]} castShadow>
          <meshStandardMaterial color="#E6E6FA" roughness={0.6} />
        </Box>
        
        {/* 眼白 - 大眼设计 */}
        <Sphere position={[-0.045, 0.025, 0.145]} args={[0.02, 14, 14]}>
          <meshStandardMaterial color="#FFFFFF" roughness={0.2} />
        </Sphere>
        <Sphere position={[0.045, 0.025, 0.145]} args={[0.02, 14, 14]}>
          <meshStandardMaterial color="#FFFFFF" roughness={0.2} />
        </Sphere>
        
        {/* 虹膜 - 迷人眼睛 */}
        <Sphere position={[-0.045, 0.025, 0.155]} args={[0.013, 12, 12]}>
          <meshStandardMaterial {...materials.eyes} />
        </Sphere>
        <Sphere position={[0.045, 0.025, 0.155]} args={[0.013, 12, 12]}>
          <meshStandardMaterial {...materials.eyes} />
        </Sphere>
        
        {/* 瞳孔 */}
        <Sphere position={[-0.045, 0.025, 0.16]} args={[0.007, 10, 10]}>
          <meshStandardMaterial color="#000000" />
        </Sphere>
        <Sphere position={[0.045, 0.025, 0.16]} args={[0.007, 10, 10]}>
          <meshStandardMaterial color="#000000" />
        </Sphere>
        
        {/* 多重高光效果 */}
        <Sphere position={[-0.04, 0.03, 0.162]} args={[0.005, 8, 8]}>
          <meshBasicMaterial color="#FFFFFF" />
        </Sphere>
        <Sphere position={[0.05, 0.03, 0.162]} args={[0.005, 8, 8]}>
          <meshBasicMaterial color="#FFFFFF" />
        </Sphere>
        <Sphere position={[-0.048, 0.02, 0.161]} args={[0.003, 6, 6]}>
          <meshBasicMaterial color="#FFFFFF" transparent opacity={0.8} />
        </Sphere>
        <Sphere position={[0.042, 0.02, 0.161]} args={[0.003, 6, 6]}>
          <meshBasicMaterial color="#FFFFFF" transparent opacity={0.8} />
        </Sphere>

        {/* 精美眼线 */}
        <Box position={[-0.045, 0.04, 0.15]} args={[0.03, 0.002, 0.01]} castShadow>
          <meshStandardMaterial color="#000000" />
        </Box>
        <Box position={[0.045, 0.04, 0.15]} args={[0.03, 0.002, 0.01]} castShadow>
          <meshStandardMaterial color="#000000" />
        </Box>

        {/* 睫毛系统 */}
        {Array.from({ length: 12 }, (_, i) => (
          <Cylinder
            key={i}
            position={[
              -0.045 + (i - 5.5) * 0.004,
              0.042,
              0.155
            ]}
            args={[0.0008, 0.0008, 0.012]}
            rotation={[0.4 + Math.random() * 0.2, (i - 5.5) * 0.05, 0]}
            castShadow
          >
            <meshStandardMaterial color="#000000" />
          </Cylinder>
        ))}
        {Array.from({ length: 12 }, (_, i) => (
          <Cylinder
            key={i + 12}
            position={[
              0.045 + (i - 5.5) * 0.004,
              0.042,
              0.155
            ]}
            args={[0.0008, 0.0008, 0.012]}
            rotation={[0.4 + Math.random() * 0.2, (i - 5.5) * 0.05, 0]}
            castShadow
          >
            <meshStandardMaterial color="#000000" />
          </Cylinder>
        ))}

        {/* 精致眉毛 - 修饰后 */}
        <Box position={[-0.045, 0.07, 0.145]} args={[0.025, 0.005, 0.006]} castShadow>
          <meshStandardMaterial {...materials.hair} />
        </Box>
        <Box position={[0.045, 0.07, 0.145]} args={[0.025, 0.005, 0.006]} castShadow>
          <meshStandardMaterial {...materials.hair} />
        </Box>
        
        {/* 眉毛高光 */}
        <Box position={[-0.045, 0.075, 0.148]} args={[0.02, 0.002, 0.003]} castShadow>
          <meshStandardMaterial color="#F5DEB3" roughness={0.3} />
        </Box>
        <Box position={[0.045, 0.075, 0.148]} args={[0.02, 0.002, 0.003]} castShadow>
          <meshStandardMaterial color="#F5DEB3" roughness={0.3} />
        </Box>

        {/* 精致鼻子 */}
        <Box position={[0, 0.005, 0.155]} args={[0.012, 0.035, 0.012]} castShadow>
          <meshStandardMaterial {...materials.skin} />
        </Box>
        
        {/* 鼻尖 */}
        <Sphere position={[0, -0.01, 0.162]} args={[0.008, 10, 10]} castShadow>
          <meshStandardMaterial {...materials.skin} />
        </Sphere>
        
        {/* 鼻翼 */}
        <Sphere position={[-0.008, -0.015, 0.16]} args={[0.006, 8, 8]} castShadow>
          <meshStandardMaterial {...materials.skin} />
        </Sphere>
        <Sphere position={[0.008, -0.015, 0.16]} args={[0.006, 8, 8]} castShadow>
          <meshStandardMaterial {...materials.skin} />
        </Sphere>

        {/* 丰满嘴唇系统 */}
        <group position={[0, -0.08, 0.15]}>
          {/* 上唇 */}
          <Sphere position={[0, 0.005, 0]} args={[0.025, 0.008, 0.008]} castShadow>
            <meshStandardMaterial {...materials.lips} />
          </Sphere>
          
          {/* 下唇 */}
          <Sphere position={[0, -0.005, 0]} args={[0.022, 0.01, 0.01]} castShadow>
            <meshStandardMaterial {...materials.lips} />
          </Sphere>
          
          {/* 唇彩高光 */}
          <Sphere position={[0, 0, 0.008]} args={[0.015, 0.006, 0.004]}>
            <meshBasicMaterial 
              color="#FFCCCB" 
              transparent 
              opacity={0.7}
            />
          </Sphere>
          
          {/* 唇线 */}
          <Box position={[0, 0, -0.002]} args={[0.028, 0.001, 0.001]} castShadow>
            <meshStandardMaterial color="#C53030" />
          </Box>
        </group>

        {/* 腮红效果 */}
        <Sphere position={[-0.085, -0.02, 0.125]} args={[0.025]} transparent>
          <meshStandardMaterial 
            color="#FBB6CE" 
            transparent 
            opacity={0.4} 
            roughness={0.8}
          />
        </Sphere>
        <Sphere position={[0.085, -0.02, 0.125]} args={[0.025]} transparent>
          <meshStandardMaterial 
            color="#FBB6CE" 
            transparent 
            opacity={0.4} 
            roughness={0.8}
          />
        </Sphere>

        {/* 面部轮廓 */}
        <Box position={[0, -0.1, 0.12]} args={[0.16, 0.06, 0.1]} castShadow>
          <meshStandardMaterial {...materials.skin} />
        </Box>
      </group>

      {/* ========== 奢华首饰系统 ========== */}
      
      {/* 垂吊式耳环 */}
      <group position={[0, 1.2 + sittingAdjust.torso, 0]}>
        {/* 左耳环 */}
        <group position={[-0.16, 0.02, 0]}>
          {/* 耳钉 */}
          <Sphere args={[0.01]} castShadow>
            <meshStandardMaterial {...materials.jewelry} />
          </Sphere>
          
          {/* 连接链 */}
          <Cylinder position={[0, -0.02, 0]} args={[0.001, 0.001, 0.03]} castShadow>
            <meshStandardMaterial {...materials.jewelry} />
          </Cylinder>
          
          {/* 主吊坠 */}
          <Sphere position={[0, -0.04, 0]} args={[0.008]} castShadow>
            <meshStandardMaterial color="#E53E3E" roughness={0.1} metalness={0.8} />
          </Sphere>
          
          {/* 装饰链条 */}
          {Array.from({ length: 5 }, (_, i) => (
            <Sphere
              key={i}
              position={[0, -0.015 - i * 0.006, 0]}
              args={[0.002]}
              castShadow
            >
              <meshStandardMaterial {...materials.jewelry} />
            </Sphere>
          ))}
        </group>
        
        {/* 右耳环 - 镜像 */}
        <group position={[0.16, 0.02, 0]}>
          <Sphere args={[0.01]} castShadow>
            <meshStandardMaterial {...materials.jewelry} />
          </Sphere>
          
          <Cylinder position={[0, -0.02, 0]} args={[0.001, 0.001, 0.03]} castShadow>
            <meshStandardMaterial {...materials.jewelry} />
          </Cylinder>
          
          <Sphere position={[0, -0.04, 0]} args={[0.008]} castShadow>
            <meshStandardMaterial color="#E53E3E" roughness={0.1} metalness={0.8} />
          </Sphere>
          
          {Array.from({ length: 5 }, (_, i) => (
            <Sphere
              key={i}
              position={[0, -0.015 - i * 0.006, 0]}
              args={[0.002]}
              castShadow
            >
              <meshStandardMaterial {...materials.jewelry} />
            </Sphere>
          ))}
        </group>
      </group>

      {/* 多层项链系统 */}
      <group position={[0, 0.95 + sittingAdjust.torso, 0.08]}>
        {/* 主项链 */}
        <Cylinder args={[0.15, 0.15, 0.006]} castShadow>
          <meshStandardMaterial {...materials.jewelry} />
        </Cylinder>
        
        {/* 项链吊坠 */}
        <group position={[0, -0.25, 0.015]}>
          {/* 主吊坠 */}
          <RoundedBox args={[0.03, 0.04, 0.008]} radius={0.005} castShadow>
            <meshStandardMaterial color="#E53E3E" roughness={0.2} metalness={0.7} />
          </RoundedBox>
          
          {/* 中央宝石 */}
          <Sphere position={[0, 0, 0.006]} args={[0.008]} castShadow>
            <meshStandardMaterial 
              color="#FFFFFF" 
              roughness={0.0} 
              metalness={0.9}
              transparent
              opacity={0.9}
            />
          </Sphere>
        </group>
        
        {/* 副项链 */}
        <Cylinder position={[0, -0.08, -0.01]} args={[0.12, 0.12, 0.004]} castShadow>
          <meshStandardMaterial color="#C0C0C0" roughness={0.1} metalness={0.9} />
        </Cylinder>
      </group>

      {/* ========== 交互效果系统 ========== */}
      
      {/* 悬停信息显示 */}
      {hovered && (
        <group position={[0, 1.8 + sittingAdjust.torso, 0]}>
          <Text
            fontSize={0.12}
            color="#E53E3E"
            anchorX="center"
            anchorY="middle"
            castShadow
          >
            {profile.name}
          </Text>
          <Text
            position={[0, -0.16, 0]}
            fontSize={0.08}
            color="#4A5568"
            anchorX="center"
            anchorY="middle"
          >
            {profile.age}岁 • {profile.occupation}
          </Text>
        </group>
      )}

      {/* 稳定魅力光环 */}
      {hovered && (
        <Cylinder 
          position={[0, 0.05, 0]} 
          args={[1.3, 1.3, 0.05]}
          rotation={[Math.PI/2, 0, 0]}
        >
          <meshLambertMaterial
            color="#FFB6C1"
            transparent
            opacity={0.08}
            side={THREE.DoubleSide}
          />
        </Cylinder>
      )}

      {/* 优雅点击特效 */}
      {clicked && (
        <>
          {Array.from({ length: 10 }, (_, i) => (
            <Text
              key={i}
              position={[
                (Math.random() - 0.5) * 2.5,
                0.8 + Math.random() * 1 + sittingAdjust.torso,
                (Math.random() - 0.5) * 2.5
              ]}
              fontSize={0.12 + Math.random() * 0.06}
              color="#FF1493"
              anchorX="center"
              anchorY="middle"
            >
              💕
            </Text>
          ))}
        </>
      )}
    </group>
  );
};